﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace Lesson01_同步_服务端_Exercises2
{
    class Program
    {
        static void Main(string[] args)
        {
            ServerSocket socket = new ServerSocket();
            socket.Start("127.0.0.1", 8080, 1024);
            while (true)
            {
                string input = Console.ReadLine();
                //关闭所有连接
                if (input == "Quit")
                {
                    socket.Close();
                }
                //广播消息
                else if (input.Substring(0, 2) == "B:")
                {
                    if (input.Length < 3)
                        return;
                    string msg = input.Substring(2);
                    socket.Broadcast(msg);
                }
            }
        }
    }
}